<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data.values"></cfg-form>
</template>

<script>
const ref = "editView";
export default {
  name: ref,
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref,
      onlyRead: false,
      loading: false,
    };
  },
  props: {
    data: {
      default: () => {
        return {};
      },
    },
  },
  watch: {},
  computed: {
    attrs() {
      return {
        labelWidth: 100,
        labelPosition: "right",
        cols: 2,
        columns: [
          {
            key: "batchNo",
            title: "批次号",
            minWidth: 200,
            align: "center",
            show: true,
            config: { readonly: true, type: "text" },
          },

          {
            key: "productId",
            title: "规格ID",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "text" },
          },
          {
            key: "status",
            title: "状态",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "text" },
          },
          {
            key: "weight",
            title: "重量(KG)",
            minWidth: 100,
            align: "center",
            show: true,
            config: { type: "number" },
          },
          // {
          //   key: "usedCapacity",
          //   title: "已用重量(KG)",
          //   minWidth: 100,
          //   align: "center",
          //   show: true,
          //   config: { type: "number" },
          // },
          // {
          //   key: "restCapacity",
          //   title: "剩余重量(KG)",
          //   minWidth: 100,
          //   align: "center",
          //   show: true,
          //   config: { type: "number" },
          // },
          {
            key: "qualityResult",
            title: "质检结果",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "text" },
          },
          {
            key: "fsssGrind",
            title: "研磨fsss",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "number" },
          },
          {
            key: "fsssOriginal",
            title: "原态fsss",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "number" },
          },
          {
            key: "ctValue",
            title: "ct值",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "number" },
          },
          {
            key: "storehouseId",
            title: "仓库Id",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "number" },
          },
          {
            key: "locationId",
            title: "库位Id",
            minWidth: 100,
            align: "center",
            show: true,
            config: { readonly: true, type: "number" },
          },
        ],
        rules: {
          weight: [
            {
              required: true,
              message: "请输入",
              trigger: "blur",
              type: "number",
            },
          ],
          // usedCapacity: [
          //   {
          //     required: true,
          //     message: "请输入",
          //     trigger: "blur",
          //     type: "number",
          //   },
          // ],
          // restCapacity: [
          //   {
          //     required: true,
          //     message: "请输入",
          //     trigger: "blur",
          //     type: "number",
          //   },
          // ],
        },
        // onlyRead: this.onlyRead,
      };
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
    });
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        if (fn) {
          return fn(valid);
        } else {
          return valid;
        }
      });
    },
    resetFields() {
      this.$refs[this.ref].$refs["form"].resetFields();
    },
  },
};
</script>
<style scoped></style>
